home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Python 1.3.3 / Python 133 SRC / Mac / Demo / interslip / InterslipLib.c next >
Text File  |  1995-11-14  |  2KB  |  98 lines

  1. /*
  2. ** InterslipLib - Routines to talk to InterSLIP. Version 1.1, 31-Oct-1995.
  3. **
  4. **
  5. ** (c) Jack Jansen, CWI, 1995 <jack@cwi.nl>
  6. */
  7.  
  8. #include <Devices.h>
  9.  
  10. #include "InterslipLib.h"
  11.  
  12. static CntrlParam iopb;
  13. static short refnum = -1;
  14.  
  15. OSErr is_open()
  16. {
  17.     if ( refnum >= 0 ) return 0;
  18.     return OpenDriver("\p.InterSLIP", &refnum);
  19. }
  20.  
  21. OSErr is_connect()
  22. {
  23.     iopb.ioCRefNum = refnum;
  24.     iopb.ioVRefNum = refnum;
  25.     iopb.ioCompletion = (UniversalProcPtr) 0;
  26.     iopb.csCode = 2;
  27.     return PBControlImmed((ParmBlkPtr)&iopb);
  28. }
  29.  
  30. OSErr is_disconnect()
  31. {
  32.     iopb.ioCRefNum = refnum;
  33.     iopb.ioVRefNum = refnum;
  34.     iopb.ioCompletion = (UniversalProcPtr) 0;
  35.     iopb.csCode = 3;
  36.     return PBControlImmed((ParmBlkPtr)&iopb);
  37. }
  38.  
  39. OSErr is_status(long *status, long *msgseqnum, StringPtr *msg)
  40. {
  41.     long *csp;
  42.     OSErr err;
  43.     
  44.     iopb.ioCRefNum = refnum;
  45.     iopb.ioVRefNum = refnum;
  46.     iopb.ioCompletion = (UniversalProcPtr) 0;
  47.     iopb.csCode = 4;
  48.     if( err = PBControlImmed((ParmBlkPtr)&iopb) )
  49.         return err;
  50.     csp = (long *)&iopb.csParam;
  51.     *status = csp[0];
  52.     *msgseqnum = csp[1];
  53.     *msg = (unsigned char *)csp[2];
  54.     return 0;
  55. }
  56.  
  57. OSErr is_getconfig(long *baudrate, long *flags, 
  58.         Str255 idrvnam, Str255 odrvnam, Str255 cfgnam)
  59. {
  60.     long *csp;
  61.     OSErr err;
  62.     
  63.     iopb.ioCRefNum = refnum;
  64.     iopb.ioVRefNum = refnum;
  65.     iopb.ioCompletion = (UniversalProcPtr) 0;
  66.     iopb.csCode = 6;
  67.     csp = (long *)&iopb.csParam;
  68.     csp[2] = (long)idrvnam;
  69.     csp[3] = (long)odrvnam;
  70.     csp[4] = (long)cfgnam;
  71.     if( err = PBControlImmed((ParmBlkPtr)&iopb) )
  72.         return err;
  73.     *baudrate = csp[0];
  74.     *flags = csp[1];
  75.     return 0;
  76. }
  77.  
  78. OSErr is_setconfig(long baudrate, long flags, 
  79.         Str255 idrvnam, Str255 odrvnam, Str255 cfgnam)
  80. {
  81.     long *csp;
  82.     OSErr err;
  83.     
  84.     iopb.ioCRefNum = refnum;
  85.     iopb.ioVRefNum = refnum;
  86.     iopb.ioCompletion = (UniversalProcPtr) 0;
  87.     iopb.csCode = 7;
  88.     csp = (long *)&iopb.csParam;
  89.     csp[0] = baudrate;
  90.     csp[1] = flags;
  91.     csp[2] = (long)idrvnam;
  92.     csp[3] = (long)odrvnam;
  93.     csp[4] = (long)cfgnam;
  94.     return PBControlImmed((ParmBlkPtr)&iopb);
  95. }
  96.  
  97.     
  98.